package com.monicaca.service;

import com.monicaca.bean.CKD;
import com.monicaca.dao.CKDDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class CKDService {
	@Autowired
	private CKDDAO CKDDAO;
	
	public CKD findByCKDId(int CKDId) {  
        return CKDDAO.findById(CKD.class, CKDId);  
    }  
	/*public RKD findByRKDName(RKD RKD) {
        return RKDDAO.findByName(RKD);
    }*/


    public List<CKD> findAll() {  
        return CKDDAO.findAll(CKD.class);  
    }
    @Transactional
    public int count1() {
        return CKDDAO.count1();
    }

    @Transactional  
    public void createCKD(CKD CKD) {  
    	CKDDAO.save(CKD);  
    }  
  
    @Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW )

    public void updateCKD(CKD CKD) {  
    	CKDDAO.update(CKD);  
    }  
  
    @Transactional  
    public void deleteCKD(int CKDId) {  
    	CKDDAO.deleteById(CKD.class, CKDId);  
    }  
  
    @Transactional  
    public void deleteCKD(CKD CKD) {  
    	CKDDAO.delete(CKD);  
    }  
}
